package Final;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

	public class Login extends JFrame {

		JButton blogin = new JButton("Login");
		JButton clogin = new JButton("Cancel");
		JPanel panel = new JPanel();
		JTextField txuser = new JTextField(15);
		JPasswordField pass = new JPasswordField(15);
		JLabel usernamelabel = new JLabel("User Name: ");
		JLabel passwordlabel = new JLabel("Password: ");
		JLabel titlelabel = new JLabel(" Login ");

		Login(){
			
			super("Login Autentification");
			setSize(300,200);
			setLocation(500,280);
			panel.setLayout (null); 
			usernamelabel.setLayout(null);
			passwordlabel.setLayout(null);

			titlelabel.setLocation(0,0);
			titlelabel.setSize(220, 30);
			titlelabel.setHorizontalAlignment(0);
			
			txuser.setBounds(100,30,150,20);
			usernamelabel.setBounds(20,30,150,20);
			pass.setBounds(100,65,150,20);
			passwordlabel.setBounds(20,65,150,20);
			blogin.setBounds(50,100,80,20);
			clogin.setBounds(160, 100, 80, 20);
			
			panel.add(titlelabel);
			panel.add(blogin);
			panel.add(clogin);
			panel.add(usernamelabel);
			panel.add(txuser);
			panel.add(passwordlabel);
			panel.add(pass);

			getContentPane().add(panel);
			setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			setVisible(true);
			actionlogin();
}

		public void actionlogin(){
			blogin.addActionListener(new ActionListener() {
		
				public void actionPerformed(ActionEvent ae) {
					String puname = txuser.getText();
					String ppaswd = pass.getText();
					if(puname.equals("test") && ppaswd.equals("1234")) {
						Companyframe compframe =new Companyframe();
						compframe.setVisible(true);
						dispose();
					} else {

						JOptionPane.showMessageDialog(null,"Wrong Password / Username");
						txuser.setText("");
						pass.setText("");
						txuser.requestFocus();
					}

				}
			});
		}
		public static void main(String[] args) {

			Login frameTabel = new Login();
		}
}
